package io.kiki.sba.registry.server.clientInterface.store;

import io.kiki.sba.registry.common.model.ClientToClientInterfaceServerNodeId;
import io.kiki.sba.registry.common.model.Tuple;

import java.util.Collection;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.function.BiConsumer;

/**
 * Session Data store manager,according base data function
 */
public interface DataManager<Data, Id, Datainfoid> {

    /**
     * new publisher and subscriber data add
     */
    boolean add(Data data);

    /**
     * query data by client node connectId
     */
    Map<Id, Data> queryByConnectId(ClientToClientInterfaceServerNodeId clientToClientInterfaceServerNodeId);

    /**
     * query data by client node connectId
     */
    Map<ClientToClientInterfaceServerNodeId, Map<Id, Data>> queryByConnectIds(Set<ClientToClientInterfaceServerNodeId> clientToClientInterfaceServerNodeIds);

    /**
     * remove data by client node connectId
     */
    Map<Id, Data> deleteByClientToClientInterfaceServerNodeId(ClientToClientInterfaceServerNodeId clientToClientInterfaceServerNodeId);

    /**
     * remove data by client node connectIds
     */
    Map<ClientToClientInterfaceServerNodeId, Map<Id, Data>> deleteByClientToClientInterfaceServerNodeIdSet(Set<ClientToClientInterfaceServerNodeId> clientToClientInterfaceServerNodeIds);

    Data queryById(Datainfoid dataInfoId, Id registerId);

    /**
     * remove single data by register id
     */
    Data deleteById(Datainfoid dataInfoId, Id registerId);

    /**
     * dataInfoId.size and data.size
     */
    Tuple<Long, Long> count();

    Set<ClientToClientInterfaceServerNodeId> getConnectIds();

    List<Data> getDataList(Datainfoid dataInfoId);

    List<Data> getDataList();

    Map<Datainfoid, Map<Id, Data>> getDatas();

    Collection<Datainfoid> getDataInfoIds();

    void forEach(BiConsumer<Datainfoid, Map<Id, Data>> consumer);
}
